package sword_offer;

import java.util.ArrayList;

/**
 * @author Synhard
 * @version 1.0
 * @Class sword_offer.TempStack
 * @Description 栈
 * @tel 13001321080
 * @email 823436512@qq.com
 * @date 2021-03-15 9:24
 */
public class TempStack<T> {
    private ArrayList<T> value; // 数据源

    public TempStack(int capacity) {
        this.value = new ArrayList<>(capacity);
    }

    public void push(T target) {
        value.add(target);
    }

    public ArrayList<T> getValue() {
        return value;
    }

    public int getLength() {
        return value.size();
    }

    public T getTop() {
        return value.get(value.size() - 1);
    }

    public T pop() {
        T temp = this.getTop();
        value.remove(value.size() - 1);
        return temp;
    }
}